<template>
  <h1>猜数字练习</h1>
  <input type="text" placeholder="输入您猜的数字" v-model="a">
  <button @click="guess">猜一猜</button>
  <h2>小提示:{{result}}</h2>
</template>

<script setup>
import {ref} from "vue";

const a=ref('');
const result=ref('');
//生成随机数
let n=parseInt(Math.random()*100)+1;
console.log(n);
const guess =()=>{
  if (a.value>n){
    result.value='猜大了';
  }else if (a.value<n){
    result.value='猜小了'
  }else {
    result.value='猜对了'
  }

}

</script>


<style scoped>

</style>